home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-07-17 | 39.9 KB | 1,258 lines |
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: December 3, 1996
- // Author: DSW
- //
- // Description:
- // File option box script.
- //
- // Input Arguments:
- // String The action being performed.
- // Open, Import, Reference, ExportAll, ExportActive, Save
- // Return Value:
- // None. Invokes the file browser.
- //
-
- global string $gFileOptionsString;
- global string $gAllOptionStrings[];
- global int $gLastOptionSelectionIndex;
- global string $gLastOptionSelection;
-
- global proc fo_prefixName ( string $action )
- //
- // Description:
- // this proc is invoked when the prefix field is changed.
- //
- {
- // Determine which field is selected.
- int $selected = `optionMenu -q -sl nameClash2OptionMenu`;
- if ($selected == 1) {
- // if "the fileName" is selected then make the edit field invisible.
- textField -e -vis false nodeNamePrefix;
- } else {
- // else make the edit field visible and fill with the option var
- textField -e -vis true nodeNamePrefix;
-
- string $renamePrefixOptionVar = ($action == "Reference" ? "referenceOptionsRenamePrefix" : "fileOptionsRenamePrefix");
- string $userPrefixStr = `optionVar -q $renamePrefixOptionVar`;
- textField -e -tx $userPrefixStr nodeNamePrefix;
- }
- }
-
- global proc fo_exportActiveNSMenuChange ()
- //
- // Description:
- // this proc is invoked when foExportActiveNSMenu is changed.
- //
- {
- // Determine which field is selected.
- int $selected = `optionMenuGrp -q -sl foExportActiveNSMenu`;
- if ($selected == 1) {
- // if "the fileName" is selected then make the edit field invisible.
- textField -e -vis false foExportActiveNSFld;
- } else {
- // else make the edit field visible and fill with the option var
- textField -e -vis true foExportActiveNSFld;
-
- string $userPrefixStr = `optionVar -q exportOptionsRenamePrefix`;
- textField -e -tx $userPrefixStr foExportActiveNSFld;
- }
- }
-
- global proc fo_exportActiveKeepRefChanged()
- //
- // Description:
- // If the "Keep Only a Reference" box is checked on, then enable
- // some UI controls; Otherwise diable the controls.
- //
- {
- int $val = `checkBoxGrp -query -v1 exKeepRefBox`;
- if ($val > 0) {
- columnLayout -edit -enable on foExportActiveReferenceLyt;
- } else {
- columnLayout -edit -enable off foExportActiveReferenceLyt;
- }
- }
-
- global proc int fo_optionsCallback ( string $newOptionsString )
- //
- // Description:
- // Set the file options string for the current translator.
- //
- {
- global string $gFileOptionsString;
-
- $gFileOptionsString = $newOptionsString;
-
- return 1;
- }
-
- global proc int fo_newFileType ( string $action )
- //
- // Description:
- // This is the callback for the file type list.
- //
- {
- string $newItem;
- string $optionsScript;
- int $numChildren;
- string $childArray[];
- string $initialSettings;
- global int $gLastOptionSelectionIndex;
- global string $gLastOptionSelection;
- global string $gAllOptionStrings[];
- global string $gFileOptionsString;
- string $lastOptions;
-
- setParent fileOptionsScroll;
-
- if ($gLastOptionSelectionIndex >= 0) {
- // Grab the last posted options before clearing.
-
- // Reselect the old item.
- if ($gLastOptionSelection != "Best Guess") {
- // Get the option Script.
- $optionsScript = `translator -q -os $gLastOptionSelection`;
- }
-
- if ($optionsScript != "") {
- // Get the new options.
- // Sets $gFileOptionsString
- eval($optionsScript+" fileOptionsScroll \"query\" \"\" fo_optionsCallback");
- } else {
- $gFileOptionsString = "";
- }
- $gAllOptionStrings[$gLastOptionSelectionIndex] = $gFileOptionsString;
- }
-
- $newItem = `optionMenuGrp -q -v fo_fileTypePopList`;
-
- // Clear out the options block.
- $numChildren = `columnLayout -q -nch fileOptionsScroll`;
- if ($numChildren > 0) {
- $childArray = `columnLayout -q -ca fileOptionsScroll`;
- string $aChildControl;
- for ($aChildControl in $childArray) {
- deleteUI $aChildControl;
- }
- }
-
- if ($newItem != "Best Guess") {
- string $translatorList[] = `translator -q -l`;
- int $numTranslators = size($translatorList);
- int $index = 0;
- for ($index = 0; $index < $numTranslators; $index++) {
- if ($translatorList[$index] == $newItem) {
- $gLastOptionSelectionIndex = $index;
- break;
- }
- }
- $gLastOptionSelection = $newItem;
- $optionsScript = `translator -q -os $newItem`;
- } else {
- $optionsScript = "";
- $gLastOptionSelectionIndex = -1;
- }
-
- separator -w 490;
- text -l "File Type Specific Options:";
-
- if ($optionsScript != "") {
- // Post the new options.
- $initialSettings = $gAllOptionStrings[$gLastOptionSelectionIndex];
- eval($optionsScript+" fileOptionsScroll \"post\" \""+$initialSettings+"\" fo_optionsCallback");
- } else {
- text -l " No Options Available" noSaveOptionsText;
- }
-
- if ($action == "ExportActive") {
-
- switch ($newItem) {
- case "Best Guess" :
- case "mayaAscii" :
- case "mayaPLE" :
- case "mayaBinary" :
- // Reset the checkboxes to the value they had the last
- // time they were used.
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportKeepOnlyRef`
- exKeepRefBox;
-
- int $exportIncludeInputs = `optionVar -query exportIncludeInputs`;
- checkBoxGrp -edit
- -en on -v1 $exportIncludeInputs
- exInInputsBox;
-
- // If the "Include These Inputs" box is enabled, then enable
- // and reset the sub options. Otherwise disable the suboptions
- // and turn them off.
- if ( $exportIncludeInputs ) {
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeHistory`
- exInHistoryBox;
-
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeChannels`
- exInChannelsBox;
-
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeExpressions`
- exInExpressionsBox;
-
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeConstraints`
- exInConstraintsBox;
- } else {
- checkBoxGrp -e -en off -v1 false exInHistoryBox;
- checkBoxGrp -e -en off -v1 false exInChannelsBox;
- checkBoxGrp -e -en off -v1 false exInExpressionsBox;
- checkBoxGrp -e -en off -v1 false exInConstraintsBox;
- }
-
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeShaders`
- exInShadersBox;
- break;
- default :
- // Other formats do not support the export filters.
- checkBoxGrp -e -en off -v1 false exKeepRefBox;
- checkBoxGrp -e -en off -v1 false exInInputsBox;
- checkBoxGrp -e -en off -v1 false exInHistoryBox;
- checkBoxGrp -e -en off -v1 false exInChannelsBox;
- checkBoxGrp -e -en off -v1 false exInExpressionsBox;
- checkBoxGrp -e -en off -v1 false exInConstraintsBox;
- checkBoxGrp -e -en off -v1 false exInShadersBox;
- break;
- }
- }
-
- return 1;
- }
-
-
- proc setOptionVars (string $action, int $forceFactorySettings)
- {
- string $translators[];
- string $optionName;
- int $index;
- string $defaultOptions;
- global string $gAllOptionStrings[];
- global int $gLastOptionSelectionIndex;
-
- if ($action == "Open") {
- if ($forceFactorySettings || !`optionVar -exists defaultFileOpenType`) {
- optionVar -stringValue defaultFileOpenType "Best Guess";
- }
- if ($forceFactorySettings || !`optionVar -exists fileExecuteSN`) {
- optionVar -intValue fileExecuteSN true;
- }
- if ($forceFactorySettings || !`optionVar -exists fileLoadDeferRef`) {
- optionVar -intValue fileLoadDeferRef false;
- }
- } else if ($action == "Import") {
- if ($forceFactorySettings || !`optionVar -exists defaultFileImportType`) {
- optionVar -stringValue defaultFileImportType "Best Guess";
- }
- if ($forceFactorySettings || !`optionVar -exists fileOptionsGrouping`) {
- optionVar -intValue fileOptionsGrouping false;
- }
- if ($forceFactorySettings || !`optionVar -exists fileOptionsRenameAll`) {
- optionVar -intValue fileOptionsRenameAll false;
- }
- if ($forceFactorySettings || !`optionVar -exists useNamespacesDuringFileIO`) {
- optionVar -intValue useNamespacesDuringFileIO false;
- }
- if ($forceFactorySettings || ! `optionVar -exists fileOptionsUseRenamePrefix`) {
- optionVar -intValue fileOptionsUseRenamePrefix false;
- }
- if ($forceFactorySettings || !`optionVar -exists fileOptionsRenamePrefix`) {
- optionVar -stringValue fileOptionsRenamePrefix "";
- }
- } else if ($action == "Reference") {
- if ($forceFactorySettings || !`optionVar -exists defaultFileReferenceType`) {
- optionVar -stringValue defaultFileReferenceType "Best Guess";
- }
- if ($forceFactorySettings || !`optionVar -exists referenceOptionsGrouping`) {
- optionVar -intValue referenceOptionsGrouping false;
- }
- if ($forceFactorySettings || !`optionVar -exists referenceUseNamespacesDuringFileIO`) {
- optionVar -intValue referenceUseNamespacesDuringFileIO false;
- }
- if ($forceFactorySettings || !`optionVar -exists referenceOptionsUseRenamePrefix`) {
- optionVar -intValue referenceOptionsUseRenamePrefix false;
- }
- if ($forceFactorySettings || !`optionVar -exists referenceOptionsRenamePrefix `) {
- optionVar -stringValue referenceOptionsRenamePrefix "";
- }
-
- } else if ($action == "ExportAll") {
- if ($forceFactorySettings || !`optionVar -exists defaultFileExportAllType`) {
- optionVar -stringValue defaultFileExportAllType "mayaBinary";
- }
- if ($forceFactorySettings || !`optionVar -exists useDefaultFileExtensions`) {
- optionVar -intValue useDefaultFileExtensions true;
- }
- } else if ($action == "ExportActive") {
- if ($forceFactorySettings || !`optionVar -exists exportOptionsGrouping`) {
- optionVar -intValue exportOptionsGrouping false;
- }
- if ($forceFactorySettings || !`optionVar -exists exportUseNamespacesDuringFileIO`) {
- optionVar -intValue exportUseNamespacesDuringFileIO false;
- }
-
- if ($forceFactorySettings || !`optionVar -exists defaultFileExportActiveType`) {
- optionVar -stringValue defaultFileExportActiveType "mayaBinary";
- }
- if ($forceFactorySettings || !`optionVar -exists exportOptionsUseRenamePrefix`) {
- optionVar -intValue exportOptionsUseRenamePrefix false;
- }
- if ($forceFactorySettings || !`optionVar -exists exportOptionsRenamePrefix`) {
- optionVar -stringValue exportOptionsRenamePrefix "";
- }
- // Keep Only a Reference.
- if ($forceFactorySettings || !`optionVar -exists exportKeepOnlyRef`) {
- optionVar -intValue exportKeepOnlyRef 0;
- }
- // Include Inputs.
- if ($forceFactorySettings || !`optionVar -exists exportIncludeInputs`) {
- optionVar -intValue exportIncludeInputs 1;
- }
- // Include History.
- if ($forceFactorySettings || !`optionVar -exists exportIncludeHistory`) {
- optionVar -intValue exportIncludeHistory 1;
- }
- // Include Channels.
- if ($forceFactorySettings || !`optionVar -exists exportIncludeChannels`) {
- optionVar -intValue exportIncludeChannels 1;
- }
- // Include Expressions.
- if ($forceFactorySettings || !`optionVar -exists exportIncludeExpressions`) {
- optionVar -intValue exportIncludeExpressions 1;
- }
- // Include Constraints.
- if ($forceFactorySettings || !`optionVar -exists exportIncludeConstraints`) {
- optionVar -intValue exportIncludeConstraints 1;
- }
- // Include Shading Groups.
- if ($forceFactorySettings || !`optionVar -exists exportIncludeShaders`) {
- optionVar -intValue exportIncludeShaders 1;
- }
- if ($forceFactorySettings || !`optionVar -exists useDefaultFileExtensions`) {
- optionVar -intValue useDefaultFileExtensions true;
- }
- } else if ($action == "Save") {
- // Incremental save options
- //
- if ($forceFactorySettings || !`optionVar -exists isIncrementalSaveEnabled`) {
- optionVar -intValue isIncrementalSaveEnabled false;
- }
- if ($forceFactorySettings || !`optionVar -exists incrementalSaveLimitBackups`) {
- optionVar -intValue incrementalSaveLimitBackups false;
- }
- if ($forceFactorySettings || !`optionVar -exists incrementalSaveMaxBackups`) {
- optionVar -intValue incrementalSaveMaxBackups 20;
- }
- } else if ($action == "SaveAs") {
- if ($forceFactorySettings || !`optionVar -exists defaultFileSaveType`) {
- optionVar -stringValue defaultFileSaveType "mayaBinary";
- }
- if ($forceFactorySettings || !`optionVar -exists useDefaultFileExtensions`) {
- optionVar -intValue useDefaultFileExtensions true;
- }
- if ($forceFactorySettings || !`optionVar -exists defaultTextureSaveAsType`) {
- optionVar -stringValue defaultTextureSaveAsType "unlessRef";
- }
- if ($forceFactorySettings || !`optionVar -exists defaultDiskCacheSaveAsType`) {
- optionVar -stringValue defaultDiskCacheSaveAsType "always";
- }
- }
-
- $translators = `translator -q -list`;
- int $numOptionStrings = size($translators);
- for ($index = 0; $index < $numOptionStrings; $index++) {
- if ($translators[$index] == "directory") continue;
- $optionName = ($translators[$index]+"Options");
- if ($forceFactorySettings || !`optionVar -exists $optionName`) {
- $defaultOptions = `translator -q -do $translators[$index]`;
- optionVar -stringValue $optionName $defaultOptions;
- }
-
- $gAllOptionStrings[$index] = `optionVar -q $optionName`;
- }
- $gLastOptionSelectionIndex = -1;
- }
-
- //
- // Procedure Name:
- // incrementalSaveStoreOptions
- //
- // Description:
- // Updates the optionVars relating to incremental save options.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc incrementalSaveStoreOptions()
- {
- // Incremental save options
- //
- int $incrementalSaveEnabled = `checkBoxGrp -q -v1 incrementalSaveEnabled`;
- optionVar -intValue isIncrementalSaveEnabled $incrementalSaveEnabled;
-
- int $limitIncrementalSaves = `checkBoxGrp -q -v1 incrementalSaveLimit`;
- optionVar -intValue incrementalSaveLimitBackups $limitIncrementalSaves;
-
- int $incrementalSaveLimit = `intSliderGrp -q -v incrementalSaveLimitNo`;
- optionVar -intValue incrementalSaveMaxBackups $incrementalSaveLimit;
- }
-
- //
- // Procedure Name:
- // incrementalSaveUpdateControls
- //
- // Description:
- // Updates the enabled/disabled state of the controls relating to
- // incremental save options.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- global proc incrementalSaveUpdateControls()
- {
- int $enableLimitCheck = false, $enableLimitValue = false;
-
- if ( `checkBoxGrp -query -value1 incrementalSaveEnabled` ) {
- $enableLimitCheck = true;
-
- if ( `checkBoxGrp -query -value1 incrementalSaveLimit` ) {
- $enableLimitValue = true;
- }
- }
-
- checkBoxGrp -edit -enable $enableLimitCheck incrementalSaveLimit;
- intSliderGrp -edit -enable $enableLimitValue incrementalSaveLimitNo;
-
- // For the incremental save options, we always store the new values into
- // the option vars immediately. This goes against our normal UI rules, but
- // it was found that users expected this behaviour in this case.
- //
- incrementalSaveStoreOptions();
- }
-
- global proc fileOptionsSetup (string $parent, string $action, int $forceFactorySettings)
- {
- string $fileType;
- string $qFileType;
- int $numTypes;
- string $typeList[];
- int $index;
-
- // Retrieve the option settings
- //
- setOptionVars ($action, $forceFactorySettings);
- setParent $parent;
-
- if ($action == "Open") {
- checkBoxGrp -edit
- -v1 `optionVar -query fileExecuteSN`
- foOpenExecuteSNGrp;
-
- checkBoxGrp -edit
- -v1 `optionVar -query fileLoadDeferRef`
- foOpenLoadDeferGrp;
- }
-
- // Set the group item if needed.
- if ($action == "Import" || $action == "Reference") {
- string $groupingOptionVar = ($action == "Reference" ? "referenceOptionsGrouping" : "fileOptionsGrouping");
- checkBoxGrp -edit
- -v1 `optionVar -query $groupingOptionVar`
- importGroupGrp;
-
- string $namespaceOptionVar = ($action == "Reference" ? "referenceUseNamespacesDuringFileIO" : "useNamespacesDuringFileIO");
- checkBoxGrp -edit
- -v1 `optionVar -query $namespaceOptionVar `
- useNamespacesGrp;
-
- if ($action == "Import") {
- if (`optionVar -q fileOptionsRenameAll`) {
- optionMenu -e -sl 2 nameClashOptions;
- } else {
- optionMenu -e -sl 1 nameClashOptions;
- }
- }
- }
-
- // Set the group item if needed.
- if ($action == "ExportActive") {
- checkBoxGrp -edit
- -v1 `optionVar -query exportUseNamespacesDuringFileIO`
- foExportActiveNSGrp;
- }
-
- // Save As Options
- switch ($action) {
- case "Save":
- // Incremental save options
- //
- int $incrementalSaveEnabled = `optionVar -query isIncrementalSaveEnabled`;
- checkBoxGrp -edit -value1 $incrementalSaveEnabled incrementalSaveEnabled;
-
- int $limitIncrementalSaves = `optionVar -query incrementalSaveLimitBackups`;
- checkBoxGrp -edit -value1 $limitIncrementalSaves incrementalSaveLimit;
-
- int $incrementalSaveLimit = `optionVar -query incrementalSaveMaxBackups`;
- intSliderGrp -edit -value $incrementalSaveLimit incrementalSaveLimitNo;
-
- incrementalSaveUpdateControls();
- break;
-
- case "SaveAs" :
- string $textOpt = `optionVar -query defaultTextureSaveAsType`;
- if ( $textOpt == "always" ) {
- radioButtonGrp -edit -sl 1 fo_saveAsTextureOption;
- } else if ( $textOpt == "unlessRef" ) {
- radioButtonGrp -edit -sl 2 fo_saveAsTextureOption;
- } else if ( $textOpt == "never" ) {
- radioButtonGrp -edit -sl 3 fo_saveAsTextureOption;
- }
-
- string $diskCacheOpt = `optionVar -query defaultDiskCacheSaveAsType`;
- if ( $diskCacheOpt == "never" ) {
- radioButtonGrp -edit -sl 2 fo_saveAsDiskCacheOption;
- } else {
- radioButtonGrp -edit -sl 1 fo_saveAsDiskCacheOption;
- }
- // !!
- // Fall Through to pick up the common control for file extensions...
- // !!
-
- case "ExportAll" :
- case "ExportActive" :
- checkBoxGrp -edit
- -v1 `optionVar -query useDefaultFileExtensions`
- useDefFileExtensions;
- break;
- default :
- break;
-
- }
-
-
- // Export Selected Options
- if ($action == "ExportActive"){
- checkBoxGrp -edit
- -en on
- -v1 `optionVar -query exportKeepOnlyRef`
- exKeepRefBox;
-
- int $exportIncludeInputs = `optionVar -query exportIncludeInputs`;
- checkBoxGrp -edit
- -en on -v1 $exportIncludeInputs
- exInInputsBox;
-
- // If the "Include These Inputs" box is enabled, then enable
- // and reset the sub options. Otherwise disable the suboptions
- // and turn them off.
- if ( $exportIncludeInputs ) {
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeHistory`
- exInHistoryBox;
-
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeChannels`
- exInChannelsBox;
-
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeExpressions`
- exInExpressionsBox;
-
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeConstraints`
- exInConstraintsBox;
- } else {
- checkBoxGrp -e -en off -v1 false exInHistoryBox;
- checkBoxGrp -e -en off -v1 false exInChannelsBox;
- checkBoxGrp -e -en off -v1 false exInExpressionsBox;
- checkBoxGrp -e -en off -v1 false exInConstraintsBox;
- }
-
- checkBoxGrp -edit
- -en on -v1 `optionVar -query exportIncludeShaders`
- exInShadersBox;
- }
-
- if ($action != "Save") {
- // Set the default read/write type.
- if ($action == "Import") {
- $fileType = `optionVar -q defaultFileImportType`;
- } else if ($action == "Reference") {
- $fileType = `optionVar -q defaultFileReferenceType`;
- } else if ($action == "Open") {
- $fileType = `optionVar -q defaultFileOpenType`;
- } else if ($action == "SaveAs") {
- $fileType = `optionVar -q defaultFileSaveType`;
- } else if ($action == "ExportAll") {
- $fileType = `optionVar -q defaultFileExportAllType`;
- } else if ($action == "ExportActive") {
- $fileType = `optionVar -q defaultFileExportActiveType`;
- } else if ($action == "CreateReference") {
- $fileType = `optionVar -q defaultFileCreateReferenceType`;
- }
-
-
- $numTypes = `optionMenuGrp -q -ni fo_fileTypePopList`;
- $typeList = `optionMenuGrp -q -ils fo_fileTypePopList`;
- for ($index = 0; $index < $numTypes; $index++) {
- $qFileType = `menuItem -q -l $typeList[$index]`;
- if ($qFileType == $fileType) {
- optionMenuGrp -e -select ($index+1) fo_fileTypePopList;
- break;
- }
- }
-
- if ($action == "Import" || $action == "Reference") {
- string $usePrefixOptionVar = ($action == "Reference" ? "referenceOptionsUseRenamePrefix" : "fileOptionsUseRenamePrefix");
- int $userPrefix = `optionVar -q $usePrefixOptionVar `;
- optionMenu -e -select ($userPrefix + 1) nameClash2OptionMenu;
- if ($userPrefix) {
- string $renamePrefixOptionVar = ($action == "Reference" ? "referenceOptionsRenamePrefix" : "fileOptionsRenamePrefix");
- string $userPrefixStr = `optionVar -q $renamePrefixOptionVar`;
- textField -e -tx $userPrefixStr nodeNamePrefix;
- }
- fo_prefixName ($action);
- }
-
- if ($action == "ExportActive") {
- int $userPrefix = `optionVar -q exportOptionsUseRenamePrefix`;
- optionMenuGrp -e -select ($userPrefix + 1) foExportActiveNSMenu;
- if ($userPrefix) {
- string $userPrefixStr = `optionVar -q exportOptionsRenamePrefix`;
- textField -e -tx $userPrefixStr foExportActiveNSFld;
- }
- fo_exportActiveNSMenuChange;
- fo_exportActiveKeepRefChanged;
- }
-
- fo_newFileType $action;
- }
-
- }
-
- global proc fileOptionsCallback (string $parent, string $action, string $actionProc)
- //
- // Description:
- // Initiate the action specified by the action button.
- // (ie. Open, Import, Save, etc.)
- //
- {
- global string $gFileOptionsString;
- global string $gAllOptionStrings[];
- global int $gLastOptionSelectionIndex;
- global string $gLastOptionSelection;
- string $fileType;
- string $optionsScript;
-
- if ($action == "Open") {
- int $useESN = `checkBoxGrp -q -v1 foOpenExecuteSNGrp`;
- optionVar -intValue fileExecuteSN $useESN;
-
- int $loadDefer = `checkBoxGrp -q -v1 foOpenLoadDeferGrp`;
- optionVar -intValue fileLoadDeferRef $loadDefer;
- }
-
- // First find out what the user has given us.
- if ($action == "Import" || $action == "Reference") {
- int $useGrp = `checkBoxGrp -q -v1 importGroupGrp`;
- string $groupingOptionVar = ($action == "Reference" ? "referenceOptionsGrouping" : "fileOptionsGrouping");
- optionVar -intValue $groupingOptionVar $useGrp;
-
- int $useNS = `checkBoxGrp -q -v1 useNamespacesGrp`;
- string $namespaceOptionVar = ($action == "Reference" ? "referenceUseNamespacesDuringFileIO" : "useNamespacesDuringFileIO");
- optionVar -intValue $namespaceOptionVar $useNS;
-
-
- int $useNamePrefix = `optionMenu -q -sl nameClash2OptionMenu`;
- string $usePrefixOptionVar = ($action == "Reference" ? "referenceOptionsUseRenamePrefix" : "fileOptionsUseRenamePrefix");
- if ($useNamePrefix == 1) {
- optionVar -intValue $usePrefixOptionVar false;
- } else {
- optionVar -intValue $usePrefixOptionVar true;
- }
-
- string $namePrefix = `textField -q -tx nodeNamePrefix`;
- if (size($namePrefix) > 0) {
- string $renamePrefixOptionVar = ($action == "Reference" ? "referenceOptionsRenamePrefix" : "fileOptionsRenamePrefix");
- optionVar -stringValue $renamePrefixOptionVar $namePrefix;
- }
-
- if ($action == "Import") {
- int $selected = `optionMenu -q -sl nameClashOptions`;
- if ($selected == 1) {
- optionVar -intValue fileOptionsRenameAll false;
- } else {
- optionVar -intValue fileOptionsRenameAll true;
- }
- }
- }
-
- if ($action == "ExportActive") {
- int $useNS = `checkBoxGrp -q -v1 foExportActiveNSGrp`;
- optionVar -intValue exportUseNamespacesDuringFileIO $useNS;
-
- int $useNamePrefix = `optionMenuGrp -q -sl foExportActiveNSMenu`;
- if ($useNamePrefix == 1) {
- optionVar -intValue exportOptionsUseRenamePrefix false;
- } else {
- optionVar -intValue exportOptionsUseRenamePrefix true;
- }
-
- string $namePrefix = `textField -q -tx foExportActiveNSFld`;
- if (size($namePrefix) > 0) {
- optionVar -stringValue exportOptionsRenamePrefix $namePrefix;
- }
- }
-
- // Set the default read/write type.
-
- if ($action != "Save") {
- $fileType = `optionMenuGrp -q -v fo_fileTypePopList`;
- }
- if ($action == "Import") {
- optionVar -stringValue defaultFileImportType $fileType;
- } else if ($action == "Reference") {
- optionVar -stringValue defaultFileReferenceType $fileType;
- } else if ($action == "Open") {
- optionVar -stringValue defaultFileOpenType $fileType;
- } else {
- if ($fileType == "Best Guess") {
- $fileType = "mayaBinary";
- }
-
- if ($action == "Save") {
- incrementalSaveStoreOptions();
- } else if ($action == "SaveAs") {
- optionVar -stringValue defaultFileSaveType $fileType;
- int $useFileExtensions = `checkBoxGrp -q -v1 useDefFileExtensions`;
- optionVar -iv useDefaultFileExtensions $useFileExtensions;
- file -defaultExtensions $useFileExtensions;
- int $butt = `radioButtonGrp -q -sl fo_saveAsTextureOption`;
- string $saveAsTexture = "";
- if ( 1 == $butt ) $saveAsTexture = "always";
- else if ( 2 == $butt ) $saveAsTexture = "unlessRef";
- else if ( 3 == $butt ) $saveAsTexture = "never";
- optionVar -stringValue defaultTextureSaveAsType $saveAsTexture;
- file -saveTextures $saveAsTexture;
- int $buttDC = `radioButtonGrp -q -sl fo_saveAsDiskCacheOption`;
- string $saveAsDiskCache = "";
- if ( 2 == $buttDC )
- $saveAsDiskCache = "never";
- else
- $saveAsDiskCache = "always";
- optionVar -stringValue defaultDiskCacheSaveAsType $saveAsDiskCache;
- file -saveDiskCache $saveAsDiskCache;
- } else if ($action == "ExportAll") {
- optionVar -stringValue defaultFileExportAllType $fileType;
- int $useFileExtensions = `checkBoxGrp -q -v1 useDefFileExtensions`;
- optionVar -iv useDefaultFileExtensions $useFileExtensions;
- file -defaultExtensions $useFileExtensions;
- } else if ($action == "ExportActive") {
- optionVar -stringValue defaultFileExportActiveType $fileType;
- if ( $fileType == "mayaAscii" ||
- $fileType == "mayaBinary" ||
- $fileType == "mayaPLE" ||
- $fileType == "Best Guess" ) {
- // Only save the value of these option boxes if the current
- // format is one for which they apply. They are forced off
- // for other formats, and we want to preserve their last
- // value for the next time a supported format is used.
- optionVar -iv exportKeepOnlyRef
- `checkBoxGrp -q -v1 exKeepRefBox`;
- optionVar -iv exportIncludeInputs
- `checkBoxGrp -q -v1 exInInputsBox`;
- optionVar -iv exportIncludeHistory
- `checkBoxGrp -q -v1 exInHistoryBox`;
- optionVar -iv exportIncludeChannels
- `checkBoxGrp -q -v1 exInChannelsBox`;
- optionVar -iv exportIncludeExpressions
- `checkBoxGrp -q -v1 exInExpressionsBox`;
- optionVar -iv exportIncludeConstraints
- `checkBoxGrp -q -v1 exInConstraintsBox`;
- optionVar -iv exportIncludeShaders
- `checkBoxGrp -q -v1 exInShadersBox`;
- }
- int $useFileExtensions = `checkBoxGrp -q -v1 useDefFileExtensions`;
- optionVar -iv useDefaultFileExtensions $useFileExtensions;
- file -defaultExtensions $useFileExtensions;
- } else if ($action == "CreateReference") {
- optionVar -stringValue defaultFileCreateReferenceType $fileType;
- }
- }
-
- if ($fileType != "Best Guess") { // We need to determine the type.
- $optionsScript = `translator -q -os $fileType`;
- }
-
- if ($optionsScript != "") {
- // Get the new options.
- // Sets $gFileOptionsString
- eval($optionsScript+" fileOptionsScroll \"query\" \"\" fo_optionsCallback");
- } else {
- $gFileOptionsString = "";
- }
-
- $gLastOptionSelectionIndex = -1; // Assume not found
-
- string $translators[] = `translator -q -list`;
- int $numTranslators = size($translators);
- for ($index = 0; $index < $numTranslators; $index++) {
- if ($translators[$index] == "directory") continue;
-
- if ($fileType == $translators[$index]) {
- $gAllOptionStrings[$index] = $gFileOptionsString;
- }
-
- $optionName = ($translators[$index]+"Options");
- optionVar -stringValue $optionName $gAllOptionStrings[$index];
- }
-
-
- // Clean up.
- $gLastOptionSelectionIndex = -1;
- string $empty[];
- $gAllOptionStrings = $empty;
-
- if ($actionProc != "") {
- // Invoke the subsequent option.
- eval($actionProc);
- }
- }
-
- proc string fileOptionsTabPage (string $action, string $tabLayout)
- {
- int $numTypes;
- string $fileTypes[];
- int $index;
- string $tabForm;
- int $readOptions;
-
- setParent $tabLayout;
-
- $tabForm = `tabLayout -tabsVisible 0 -scrollable 1`;
- string $topForm = `formLayout optionsBoxForm`;
-
- formLayout actionOptionsForm;
- if ($action == "Import" || $action == "Reference") {
- // We need to ask for grouping information.
- columnLayout genOptionsLayout;
- checkBoxGrp -numberOfCheckBoxes 1
- -label "Group" -label1 ""
- importGroupGrp;
-
- checkBoxGrp -numberOfCheckBoxes 1
- -label "Use Namespaces" -label1 ""
- useNamespacesGrp;
-
- separator -w 490;
- formLayout nameClashForm;
- text -l "Name clash options:" nameClassTitle;
-
- if ($action == "Reference") {
- optionMenu -l "Resolve" nameClashOptions;
- menuItem -l "all nodes" prefixOptionMenu1;
- } else {
- optionMenu -l "Resolve" nameClashOptions;
- menuItem -l "clashing nodes" prefixOptionMenu1;
- menuItem -l "all nodes" prefixOptionMenu2;
- }
-
- optionMenu -l "with" -cc ("fo_prefixName (\"" + $action + "\")") nameClash2OptionMenu;
- menuItem -l "the file name" prefixOptionMenu3;
- menuItem -l "this string:" prefixOptionMenu4;
-
- textField -w 152 nodeNamePrefix;
-
- formLayout -e
- -af nameClassTitle top 5
- -af nameClassTitle left 6
- -ac nameClashOptions top 5 nameClassTitle
- -af nameClashOptions left 10
- -ac nameClash2OptionMenu top 5 nameClassTitle
- -ac nameClash2OptionMenu left 0 nameClashOptions
- -ac nodeNamePrefix top 5 nameClassTitle
- -ac nodeNamePrefix left 3 nameClash2OptionMenu
- nameClashForm;
-
- setParent ..;
- separator -w 490;
-
- $readOptions = 1;
-
- } else if ($action == "Open") {
- $readOptions = 1;
- } else {
- $readOptions = 0;
- }
-
- setParent actionOptionsForm;
- if ($action != "Save") {
- optionMenuGrp -l "File Type" -cc ("fo_newFileType "+$action)
- -cat 1 "left" 5 -cw 1 65 fo_fileTypePopList;
- if ($readOptions) {
- menuItem -l "Best Guess" "fo_AnyfileTypeMenu";
- }
- $fileTypes = `translator -q -l`;
- $numTypes = size($fileTypes);
- for ($index = 0; $index < $numTypes; $index++) {
- if ($readOptions) {
- if (`translator -q -rs $fileTypes[$index]`) {
- menuItem -l $fileTypes[$index] ($fileTypes[$index]+"fo_fileTypeMenu");
- }
- } else if (`translator -q -ws $fileTypes[$index]`) {
- if ($action == "SaveAs") {
- if ($fileTypes[$index] == "mayaAscii"
- || $fileTypes[$index] == "mayaPLE"
- || $fileTypes[$index] == "mayaBinary") {
- menuItem -l $fileTypes[$index] ($fileTypes[$index]+"fo_fileTypeMenu");
- }
- } else {
- menuItem -l $fileTypes[$index] ($fileTypes[$index]+"fo_fileTypeMenu");
- }
- }
- }
- }
-
- if ($action == "Open") {
- setUITemplate -pushTemplate DefaultTemplate;
- columnLayout openOptionColumn;
- separator -w 490;
-
- checkBoxGrp -ncb 1
- -label "Execute Script Nodes" -label1 ""
- foOpenExecuteSNGrp;
-
- checkBoxGrp -ncb 1
- -label "Load Deferred References" -label1 ""
- foOpenLoadDeferGrp;
-
- formLayout -e
- -af fo_fileTypePopList top 0
- -af fo_fileTypePopList left 0
- -ac openOptionColumn top 0 fo_fileTypePopList
- -af openOptionColumn left 0
- -af openOptionColumn bottom 0
- -af openOptionColumn right 0
- actionOptionsForm;
- setUITemplate -popTemplate;
- }
-
- if ($action == "Import" || $action == "Reference") {
- formLayout -e
- -ac fo_fileTypePopList top 5 genOptionsLayout
- -af fo_fileTypePopList left 0
- actionOptionsForm;
- } else if ($action != "Save") {
- formLayout -e
- -af fo_fileTypePopList top 0
- -af fo_fileTypePopList left 0
- actionOptionsForm;
- }
-
- if ($action == "Save" || $action == "SaveAs"
- || $action == "ExportAll"){
- setUITemplate -pushTemplate DefaultTemplate;
- columnLayout saveAsOptionColumn;
- if ( $action == "SaveAs" || $action == "ExportAll"){
- separator -w 490;
- checkBoxGrp -numberOfCheckBoxes 1
- -label "Default File Extensions"
- -label1 "" useDefFileExtensions;
-
- formLayout -e
- -af fo_fileTypePopList top 0
- -af fo_fileTypePopList left 0
- -ac saveAsOptionColumn top 0 fo_fileTypePopList
- -af saveAsOptionColumn left 0
- -af saveAsOptionColumn bottom 0
- -af saveAsOptionColumn right 0
- actionOptionsForm;
- }
- if ( $action == "Save" ) {
-
- // Incremental save options
- //
- checkBoxGrp -label1 "Incremental Save"
- -changeCommand1 "incrementalSaveUpdateControls"
- incrementalSaveEnabled;
-
- checkBoxGrp -label1 "Limit Incremental Saves"
- -changeCommand1 "incrementalSaveUpdateControls"
- incrementalSaveLimit;
-
- intSliderGrp -label "Number of Increments"
- -min 1
- -max 100
- incrementalSaveLimitNo;
- }
- if ( $action == "SaveAs" ) {
- //
- separator -w 490;
- text -l " 3D Paint Texture Options: ";
- text -l "";
- text -l " Copy Texture Maps on Save Scene As ";
- radioButtonGrp -l "" -nrb 3 -cw4 50 100 150 100
- -l1 "Always" -l2 "Unless Referenced" -l3 "Never"
- fo_saveAsTextureOption;
-
- separator -w 490;
- text -l " Disk Cache Options: ";
- text -l "";
- text -l " Copy Jiggle Disk Cache Files on Save Scene As ";
- radioButtonGrp -l "" -nrb 2 -cw3 50 100 150
- -l1 "Always" -l2 "Never"
- fo_saveAsDiskCacheOption;
- }
- setUITemplate -popTemplate;
- }
-
- if ($action == "ExportActive"){
- setUITemplate -pushTemplate DefaultTemplate;
- columnLayout exportOptionColumn;
- separator -w 490;
- checkBoxGrp -numberOfCheckBoxes 1
- -label "Default File Extensions"
- -label1 "" useDefFileExtensions;
-
- formLayout -e
- -af fo_fileTypePopList top 0
- -af fo_fileTypePopList left 0
- -ac exportOptionColumn top 0 fo_fileTypePopList
- -af exportOptionColumn left 0
- -af exportOptionColumn bottom 0
- -af exportOptionColumn right 0
- actionOptionsForm;
-
- separator -w 490;
-
- checkBoxGrp
- -changeCommand fo_exportActiveKeepRefChanged
- -numberOfCheckBoxes 1
- -label "Keep Only a Reference"
- -label1 ""
- exKeepRefBox;
-
- columnLayout foExportActiveReferenceLyt;
-
- checkBoxGrp
- -numberOfCheckBoxes 1
- -label "Use Namespaces"
- -label1 ""
- foExportActiveNSGrp;
-
- rowLayout -nc 2
- -cw2 340 200
- -ct2 "left" "left"
- -cl2 "left" "left" -adj 2
- foExportActiveNSLyt;
-
- optionMenuGrp -l "Prefix with:"
- -cw 2 125
- -cc fo_exportActiveNSMenuChange
- foExportActiveNSMenu;
- menuItem -l "the file name";
- menuItem -l "this string";
-
- textField -w 152 foExportActiveNSFld;
- setParent ..;
- setParent ..;
-
- separator -w 490;
-
- checkBoxGrp
- -ncb 1
- -l ""
- -l1 "Include These Inputs:"
- -cw 1 100
- -onCommand
- ("checkBoxGrp -e -enable on -v1 on exInHistoryBox;"+
- "checkBoxGrp -e -enable on -v1 on exInChannelsBox;"+
- "checkBoxGrp -e -enable on -v1 on exInExpressionsBox;"+
- "checkBoxGrp -e -enable on -v1 on exInConstraintsBox;")
- -offCommand
- ("checkBoxGrp -e -enable off -v1 off exInHistoryBox;"+
- "checkBoxGrp -e -enable off -v1 off exInChannelsBox;"+
- "checkBoxGrp -e -enable off -v1 off exInExpressionsBox;"+
- "checkBoxGrp -e -enable off -v1 off exInConstraintsBox;")
- exInInputsBox;
-
- columnLayout -adjustableColumn 1 exportOptionColumn;
-
- checkBoxGrp
- -ncb 1
- -l1 "History"
- exInHistoryBox;
-
- checkBoxGrp
- -ncb 1
- -l1 "Channels"
- exInChannelsBox;
-
- checkBoxGrp
- -ncb 1
- -l1 "Expressions"
- exInExpressionsBox;
-
- checkBoxGrp
- -ncb 1
- -l1 "Constraints"
- exInConstraintsBox;
-
- setParent "..";
-
- checkBoxGrp
- -ncb 1
- -l " "
- -l1 "Include Texture Info"
- -cw 1 100
- exInShadersBox;
-
- setUITemplate -popTemplate;
- }
-
-
- setParent $topForm;
- columnLayout fileOptionsScroll;
-
- formLayout -e -af actionOptionsForm top 0
- -af actionOptionsForm left 0
- -af actionOptionsForm right 0
- -ac fileOptionsScroll top 5 actionOptionsForm
- -af fileOptionsScroll left 5
- -af fileOptionsScroll right 5
- -af fileOptionsScroll bottom 0
- optionsBoxForm;
-
- return $tabForm;
- }
-
-
- global proc fileOptions (string $action, string $actionProc)
- {
- string $cmdName = "fileOptions";
- string $optionBoxTitle;
- string $actionName;
-
- if($action == "Open") $actionName = "Open";
- else if ($action == "Import") $actionName = "Import";
- else if ($action == "Reference") $actionName = "Reference";
- else if ($action == "Save") $actionName = "Save Scene";
- else if ($action == "SaveAs") $actionName = "Save Scene As";
- else if ($action == "ExportAll") $actionName = "Export All";
- else if ($action == "ExportActive") $actionName = "Export Selection";
-
- $optionBoxTitle = ($actionName+" Options");
-
- // Build the option box "methods"
- //
- string $callback = ($cmdName + "Callback");
- string $setup = ($cmdName + "Setup");
-
-
- // Build the window, with a tab layout
- //
- setUITemplate -pushTemplate DefaultTemplate;
- string $widgetList[] = `getStandardWindow $optionBoxTitle 1 "noScroll"`;
-
- setOptionBoxCommandName($actionName);
-
- // Make the form invisible while we create the widgets in the window
- //
- formLayout -e -vis false $widgetList[1];
-
-
- // Attach each tab
- //
- string $tabPage = `fileOptionsTabPage $action $widgetList[2]`;
- tabLayout -e -tabLabel $tabPage "Basic" $widgetList[2];
-
- // Attach the standard buttons
- //
- string $buttonList[] =
- `addStandardButtons $cmdName $actionName $widgetList[1] $widgetList[2] "noOptions"`;
-
- // attach commands to the standard buttons
- //
- button -e -command ("hideOptionBox") $buttonList[2];
- button -e -command ($setup + " " + $widgetList[0] + " " + $action + " true")
- $buttonList[1];
- button -e -command ($callback+" "+$widgetList[0]+" "+$action+" \""+$actionProc+"\"")
- $buttonList[0];
-
-
- // Make the form layout visible so we can see what we built, and
- // reset the template
- //
- formLayout -e -vis true $widgetList[1];
- setUITemplate -popTemplate;
-
- button -e -command ($callback+" "+$widgetList[0]+" "+$action+" \"\"")
- $buttonList[3];
-
- // Customize the 'Help' menu item text.
- //
- switch ($action) {
- case "Open":
- setOptionBoxHelpTag( "OpenSceneOptions" );
- break;
- case "Import":
- setOptionBoxHelpTag( "ImportOptions" );
- break;
- case "Reference":
- setOptionBoxHelpTag( "CreateReferenceOptions" );
- break;
- case "Save":
- setOptionBoxHelpTag( "SaveSceneOptions" );
- break;
- case "SaveAs":
- setOptionBoxHelpTag( "SaveSceneAsOptions" );
- break;
- case "ExportAll":
- setOptionBoxHelpTag( "ExportAllOptions" );
- break;
- case "ExportActive":
- setOptionBoxHelpTag( "ExportSelectionOptions" );
- break;
- }
-
-
- // Call the setup "method" to fill in the current settings
- //
- eval (($setup + " " + $widgetList[0] + " " + $action + " false"));
- showOptionBox();
- showWindow $widgetList[0];
- }
-